package com.fenqing.leetcode.code.t500_600;

import com.fenqing.core.design.DesignTopic;

import java.util.HashMap;
import java.util.Map;
import java.util.UUID;

public class Topic535 extends DesignTopic {
    public Topic535(String methods, String params) {
        super(methods, params);
    }

    public static class Codec {

        Map<String, String> map = new HashMap<>();

        // Encodes a URL to a shortened URL.
        public String encode(String longUrl) {
            String s = UUID.randomUUID().toString().replaceAll("-", "");
            map.put(s, longUrl);
            return s;
        }

        // Decodes a shortened URL to its original URL.
        public String decode(String shortUrl) {
            return map.get(shortUrl);
        }
    }

}
